﻿@namespace MudBlazor.Docs.Examples

<MudGrid>
    <MudItem xs="12" sm="6" md="4">
        <MudSelect T="Pizza" @bind-Value="@pizza" Label="Select your pizza" Variant="Variant.Outlined" ToStringFunc="@converter" OffsetY="true">
            <MudSelectItem Value="@(new Pizza() { Name="Cardinale"})" />
            <MudSelectItem Value="@(new Pizza() { Name="Diavolo"})" />
            <MudSelectItem Value="@(new Pizza() { Name="Margarita"})" />
            <MudSelectItem Value="@(new Pizza() { Name="Spinaci"})" />
        </MudSelect>
    </MudItem>
    <MudItem xs="12" sm="6" md="4">
        @if(pizza==null) {
            <MudText Class="mt-5">Nothing selected yet.</MudText>
        }        
        else {
            <MudText Class="mt-5">Pizza: @pizza.Name</MudText>
        }
    </MudItem>    
</MudGrid>

@code {
    Pizza pizza;

    public class Pizza
    {
        public string Name { get; set; }
    }

    Func<Pizza,string> converter = p => p?.Name;
}